<?php
/*
+--------------------------------------------------------------------------
|   Arka-Tech Web Application Desktop (Vision) v2.0.0
|   ========================================
|   by Christopher Hall
|   (c) 2009 Arka-Tech Productions
|   http://arka-tech.net
|   ========================================
|   Web: http://Arka-Tech.net
|   Time: Wed, 15 July 2009 8:42 AM
|   Release: RmVicnVhcnkgMjAwOSBMYXVuY2ggNA==
|   Email: Arkahn@live.ca
|   Licence Info: http://www.arka-tech.net/
+---------------------------------------------------------------------------
|
|   > Main Launcher Script
|   > Script written by Christopher Hall
|   > Date started: 20th March 2009
|
+--------------------------------------------------------------------------
*//*
require ('GLOBAL.php');
$vision[] = array(
	'version' => init::desktop
);
print_r($vision);
//atwaController::run();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" version="-//W3C//DTD XHTML 1.1//EN" xml:lang="en">
<!-- head -->
<head>
<?php include ('Vision/scripts.php'); ?>
<title>Arka-Tech Vision</title>
</head>
<script type="text/javascript">
var Welcome = new Window({className: "Vista", blurClassName: "Vista",  width:420, height:550, zIndex: 100, resizable: true, title: "<img src=\"images/Vision/welcome_center_icon.png\" height=\"18px\" width=\"18px\" />Welcome to Arka-Tech OSWOS (Vision)", showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff, draggable:true, wiredDrag: true, url: "Welcome/index.php"})

var MiniBrowser = new Window({className: "Browser", title: "<img src=\"images/Vision/mini_web_browser_icon.png\" height=\"18px\" width=\"18px\" />Arka-Tech Mini Browser ~ BETA", top:90, left:75, width:800, height:500, url: "<?php echo $URL; ?>", showEffectOptions: {duration:1.5}})

var siteBrowser = new Window({className: "Browser", title: "<img src=\"images/Vision/mini_web_browser_icon.png\" height=\"18px\" width=\"18px\" />Arka-Tech site Browser ~ BETA", top:90, left:75, width:800, height:500, url: "default.php?page=Welcome", showEffectOptions: {duration:1.5}})
<?php
# begin including software
?>
</script>
<!-- body -->
<body>
<b><?php echo $name['ADMIN'].$version['Vision']; ?></b><br />
<br />
<div id="welcome"><a href="#" onclick="Welcome.show();"><img src="images/Vision/welcome_center_icon.png" />Welcome to Arka-Tech OSWOS (Vision)</a></div>
<br />
<br />
<div id="web_browser"><a href="#" onclick="Browser.show();"><img src="images/Vision/web_browser_icon.png" />Arka-Tech Web Browser ~ BETA</a></div>
<br />
<br />
<div id="web_browser"><a href="#" onclick="MediaPlayer.show();"><img src="images/Vision/Arka-Tech Productions100x100.png" />Media Player ~ BETA</a></div>
<br />
<br />
<div id="Paint"><a href="#" onclick="Paint.show();"><img src="Vision/Programs/paint/favicon.ico" />PIXASTIC</a></div>
<br />
<br />
<div id="production"><a href="#" onclick="MiniBrowser.show();"><img src="images/Vision/production_center_icon.png" />Arka-Tech Vision&copy; Updates</a></div>
<br />
<br />
<div id="web_browser"><a href="#" onclick="siteBrowser.show();"><img src="images/Vision/Arka-Tech Productions100x100.png" />View your website!</a></div>
<br />
<br />
<div id="web_browser"><a href="#" onclick="System.show();"><img src="images/Vision/Arka-Tech Productions100x100.png" />Arka-Tech System Info ~ Beta</a></div>
<br />
<br />
<!-- dock -->
<div id="dock">
	<div id="theme"> Theme:
		<select>
			<option>Vista</option>
		</select>
	</div>
</div>
<!-- startup scripts -->
<script type="text/javascript">
<!-- BEGIN STARTUP PROGRAMS -->
Dialog.alert({url: "Vision/docs/info_panel.php", options: {method: 'get'}}, 
            {className: "Vista", width:540, okLabel: "Close"});
  Welcome.show();
<!-- END STARTUP PROGRAMS -->
</script>
<!-- load software -->
<?php
# include software
$URL = "http://arka-tech.net/OS/index.php";
include ('Vision/Programs/Browser.php');
include ('Vision/Programs/Paint.php');
include ('Vision/Programs/System.php');
include ('Vision/Programs/Media.php');
?>
<!-- end page -->
<script>
WindowStore.showCenter(Welcome);
WindowStore.init();
</script>
</body>
</html>
<?php*/
/*
+---------------------------------------------------------------------------
|   Arka-Tech Web Application v2.0.0
|   ========================================
|   by Christopher Hall
|   (c) 2009 ArkahnX-Technology
|   http://arka-tech.net
|   ========================================
|   Web: http://arka-tech.net/os/
|   Time: Teus, 15 July 2009 7:36 PM
|   Release: RmVicnVhcnkgMjAwOSBMYXVuY2ggNA==
|   Email: ArkahnX@gmail.com
|   Licence Info: http://www.arka-tech.net/os/
+---------------------------------------------------------------------------
*/

//Exit when requested
if(isset($_REQUEST['exit'])) {
	reqLib('Sessions','endSession');
}
global $currentUser;
//Check for logged user
$currentUser = $_SESSION["mobile_user"];
$messageBox = "";

//Do login on username and password requests receivement
if(empty($currentUser) && isset($_REQUEST["username"]) && isset($_REQUEST["password"])) {
	if(um('login', array($_REQUEST["username"], $_REQUEST["password"]))) {
		$currentUser = $_REQUEST["username"];
		$_SESSION["mobile_user"] = $_REQUEST["username"];
	} else $messageBox = "<div class='messageBox'>Wrong user or password.</div>";
}

if(empty($currentUser)) {
	//Draw login page
	echo '<?xml version="1.0" encoding="UTF-8"?>
	<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
	<html>
		<head>
			<title>Welcome to ATWA Mobile</title>
			<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
		  	<style type="text/css">
				body {
					background-color:#FFFFFF;
					font-family:sans-serif;
					margin:0px;
				}
				.messageBox {
					padding: 10px 4px;
					background-color: #e6f3fc;
				}
			</style>
		</head>
		<body>
			<img style="margin-left: 5px; margin-top: 5px;" src="mobile-logo.png" />
			'.$messageBox.'
			<div class="messageBox">
				<strong>eyeOS Mobile login:</strong><br />
				<form action="index.php" method="post">
					<input name="username" type="text" /><br /><br />
					<input name="password" type="password" /><br /><br />
					<input type="submit" value="Login" />
				</form>
			</div>
		</body>
	</html>';
} else {
	//Draw file list
	
	
	//Pick current userdir and path
	$dir = um('getCurrentUserDir')."files/";
	$userPath = "";

	if(isset($_REQUEST["path"]) && vfs('isdir', array($dir.$userPath))) {
		$userPath = trim($_REQUEST['path']);
		$dir = $dir.$userPath;
	}
	
	//Include some functions -create directory, upload files, download files-
	include_once("../mobile/mobile_functions.eyecode");
	
	echo '<?xml version="1.0" encoding="UTF-8"?>
	<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
	<html>
	<head>
		<title>ATWA Mobile</title>
		<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
		<style type="text/css">
			body {
				background-color:#FFFFFF;
				font-family:sans-serif;
				margin:0px;
				font-size:90%;
			}
			a:link, a:visited {
				text-decoration: none;
				color: #2560d9;
			}
			
			a:hover {
				text-decoration: none;
			}
			
			.listfile {
				border-top: 1px solid #ddd;
				padding: 4px;
			}
			
			.path {
				background-color: #e6f3fc;
				border-bottom: 1px solid #88c2e8;
				font-size:90%;
				padding: 4px;
			}
			.graybg {
				border-top: 1px solid #ddd;
				padding: 10px 4px;
				background-color: #f7f7f7;
			}
			.optionsText {
				color: #555;
			}
		</style>
	</head>
	<body>
	';
	
	//Display the path links
	$link = "";
	$splittedPath = explode ('/', $userPath);
	echo "<div class='path'><img style='margin-bottom: -3px;' src='index.php?theme=1&extern=icons/16x16/folder_open.png' /> <a href='index.php'>Home</a>";
	foreach ($splittedPath as $i) {
		if (!empty($i)) {
			$link .= $i."/";
			echo " / "."<a href='index.php?path=".$link."'>$i</a>";
		}
	}
	echo "</div><br />";
	
	//List the files
	$fileList = vfs('getDirContent', array($dir));
	if(is_array($fileList)) {
		sort($fileList);
		foreach($fileList as $file) {
			if(vfs('isdir', array($file))) {
				$file = utf8_basename($file);
				echo "\n\t\t<div class='listfile'><a href='index.php?path=".$userPath.$file."/'><img style='margin-bottom: -1px;' border='0' src='index.php?theme=1&extern=icons/16x16/folder.png' /> $file</a></div>";
			} else {
				$file = utf8_basename($file);
				echo "\n\t\t<div class='listfile'><a href='index.php?download=".$userPath.$file."'><img style='margin-bottom: -1px;' border='0' src='index.php?theme=1&extern=icons/16x16/file.png' /> $file</a></div>";
			}
		}
	} else {
		echo "This directory is empty.<br />";
	}
	
	//Draw the bottom forms -create directory, upload files-
	echo '<div class="graybg">
	  <img style="margin-bottom: -2px;" border="0" src="index.php?theme=1&extern=icons/16x16/upload.png" /> <span class="optionsText">Upload a file:</span> <br />
	  <form action="index.php?action=upload" enctype="multipart/form-data" method="post">
	    <input name="file" type="file" />
	    <input type="hidden" name="path" value="'.$userPath.'" />
	    <input name="Submit" type="Submit" value="Upload" />
	  </form><br />
	  <img style="margin-bottom: -2px;" border="0" src="index.php?theme=1&extern=icons/16x16/newfolder.png" /> <span class="optionsText">Create a directory:</span><br />
	  <form action="index.php" method="post">
	    <input type="hidden" name="path" value="'.$userPath.'" />
	    <input type="text" name="dirname" maxlength="15" />
	    <input name="Submit" type="Submit" value="Create" />  
	  </form></div>	<small><a href="index.php?exit">Sign out</a> - <a href="../index.php">Desktop version</a></small>
	</body>
	</html>';
}
?>